home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / t_unix / j109lxa4.tar / files.c < prev    next >
C/C++ Source or Header  |  1994-06-04  |  24KB  |  751 lines

  1. /* System-dependent definitions of various files, spool directories, etc */
  2. /* Mods by PA0GRI */
  3. /* Modified to allow for configurable file names/locations - WG7J */
  4. #include <stdio.h>
  5. #include "global.h"
  6. #include "config.h"
  7. #include "netuser.h"
  8. #include "files.h"
  9.  
  10. #ifdef    MSDOS
  11. char *Startup    = "/autoexec.nos";        /* Initialization file */
  12. char *Userfile    = "/ftpusers";            /* Authorized FTP users and passwords */
  13. char *Hostfile    = "/net.rc";            /* hosts and passwords */
  14. char *Maillog    = "/spool/mail.log";        /* mail log */
  15. char *Mailspool    = "/spool/mail";        /* Incoming mail */
  16. char *Mailqdir    = "/spool/mqueue";        /* Outgoing mail spool */
  17. char *Mailqueue    = "/spool/mqueue/*.wrk";    /* Outgoing mail work files */
  18. char *Routeqdir    = "/spool/rqueue";        /* queue for router */
  19. char *Alias    = "/alias";            /* the alias file */
  20. char *Dfile    = "/domain.txt";        /* Domain cache */
  21. char *Fdir    = "/finger";            /* Finger info directory */
  22. char *Fdbase = "/finger/dbase.dat"; /* Finger database */
  23. char *Arealist  = "/spool/areas";       /* List of message areas */
  24. char *Rewritefile = "/spool/rewrite";       /* Address rewrite file */
  25. char *Ftpmotd = "/spool/ftpmotd.txt";       /* FTP message of the day */
  26. #ifdef MAILBOX
  27. char *Signature = "/spool/signatur";        /* Mail signature file directory */
  28. char *Historyfile = "/spool/history";       /* Message ID history file */
  29. char *Helpdir   = "/spool/help";        /* Mailbox help file directory */
  30. char *Motdfile = "/spool/motd.txt";     /* Mailbox message of the day */
  31. #ifdef USERLOG
  32. char *UDefaults = "/spool/users.dat";       /* User preference file */
  33. char *UDefbak = "/spool/users.bak";
  34. #endif
  35. #endif /* MAILBOX */
  36. #ifdef CONVERS
  37. char *Cinfo = "/finger/dbase.dat";  /* Convers user info file */
  38. #endif
  39. #if (defined(POP) || defined(POP2CLIENT) || defined(POP2SERVER) || defined(POP3CLIENT) || defined(POP3SERVER))
  40. char *Popusers  = "/popusers";          /* POP user and password file */
  41. #endif
  42. #if (defined(NNTP) || defined(NNTPS))
  43. char *Newsdir   = "/spool/news";        /* News messages and NNTP data */
  44. #endif
  45. #ifdef MBFWD
  46. char *Forwardfile = "/spool/forward.bbs";   /* Mail forwarding file */
  47. #endif
  48. #ifdef NETROM
  49. char *Netromfile = "/netrom.sav";       /* Netrom node save file */
  50. #endif
  51. char *Onexit = "/onexit.nos";           /* Commands to be executed on exiting */
  52. #ifdef EXPIRY
  53. char *Expirefile = "/spool/expire.dat"; /* Message expiration control file */
  54. #endif
  55. #ifdef    NNTPS
  56. char *Active    = "/spool/news/active";        /* */
  57. char *Pointer    = "/spool/news/pointer";    /* */
  58. char *NInfo    = "/spool/news/info";        /* */
  59. char *Nhelp    = "/spool/news/help";        /* */
  60. char *History    = "/spool/news/history";    /* */
  61. char *Forward    = "/spool/news/forward";    /* */
  62. char *Poll    = "/spool/news/poll";        /* */
  63. #endif
  64. char Eol[]    = "\r\n";
  65. #define    SEPARATOR    "/"
  66. #define ROOTDIR "/"
  67. #endif
  68.  
  69. #ifdef    UNIX
  70. /*
  71.  * DOS compatible names now used.  If you used the old names, use compat.cfg
  72.  * as a configuration file to get things working, then rename/symlink as needed
  73.  * --- the new names are the same as the old DOS ones, so it should be easy.
  74.  *
  75.  * We now use this more as a resource file than as merely a list of filenames
  76.  * (we can get away with it, where this costs precious memory in DOS).  Some
  77.  * of the things found here are the default session managers for the Command
  78.  * and Trace sessions and color information (when implemented).
  79.  */
  80. char *Startup    = "./autoexec.nos";        /* Initialization file */
  81. char *Hostfile    = "./net.rc";            /* hosts and passwords */
  82. char *Userfile    = "./ftpusers";
  83. char *Ftpmotd   = "./spool/ftpmotd.txt";       /* FTP message of the day */
  84. char *Mailspool    = "./spool/mail";
  85. char *Maillog    = "./spool/mail.log";            /* mail log */
  86. char *Mailqdir    = "./spool/mqueue";
  87. char *Mailqueue    = "./spool/mqueue/*.wrk";
  88. char *Routeqdir    = "./spool/rqueue";            /* queue for router */
  89. char *Alias    = "./alias";            /* the alias file */
  90. char *Dfile    = "./domain.txt";        /* Domain cache */
  91. char *Fdir    = "./finger";            /* Finger info directory */
  92. char *Motdfile  = "./spool/motd.txt";     /* Mailbox message of the day */
  93. char *Fdbase = "./finger/dbase.dat"; /* Finger database */
  94. char *Arealist  = "./spool/areas";            /* List of message areas */
  95. char *Helpdir    = "./spool/help";            /* Mailbox help file directory */
  96. char *Rewritefile = "./spool/rewrite";        /* Address rewrite file */
  97. char *Signature    = "./spool/signatur";            /* Mail signature file directory */
  98. char *Popusers    = "./popusers";            /* POP user and password file */
  99. char *Newsdir    = "./spool/news";            /* News messages and NNTP data */
  100. char *Forwardfile = "./spool/forward.bbs";        /* Mail forwarding file */
  101. char *Historyfile = "./spool/history";        /* Message ID history file */
  102. char *Netromfile = "./netrom.sav";        /* Netrom node save file */
  103. char *UDefaults = "./spool/users.dat";       /* User preference file */
  104. char *UDefbak = "./spool/users.bak";
  105. #ifdef CONVERS
  106. char *Cinfo = "./finger/dbase.dat";  /* Convers user info file */
  107. #endif
  108. char *Onexit = "./onexit.nos";           /* Commands to be executed on exiting */
  109. char *Expirefile = "./spool/expire.dat"; /* Message expiration control file */
  110. #ifdef    NNTPS
  111. char *Active    = "./spool/news/active";        /* */
  112. char *Pointer    = "./spool/news/pointer";    /* */
  113. char *NInfo    = "./spool/news/info";        /* */
  114. char *Nhelp    = "./spool/news/help";        /* */
  115. char *History    = "./spool/news/history";    /* */
  116. char *Forward    = "./spool/news/forward";    /* */
  117. char *Poll    = "./spool/news/poll";        /* */
  118. #endif
  119. char Eol[]    = "\n";
  120. #define    SEPARATOR    "/"
  121. #define ROOTDIR "."
  122. /* default session managers */
  123. char *Command_sessmgr = "";
  124. char *Trace_sessmgr = "";
  125. #endif
  126.  
  127. #ifdef    AMIGA
  128. char *Startup    = "TCPIP:nos-startup";
  129. char *Config    = "TCPIP:config.nos";        /* Device configuration list */
  130. char *Hostfile    = "TCPIP:net.rc";        /* hosts and passwords */
  131. char *Userfile    = "TCPIP:ftpusers";
  132. char *Mailspool    = "TCPIP:spool/mail";
  133. char *Maillog    = "TCPIP:spool/mail.log";
  134. char *Mailqdir    = "TCPIP:spool/mqueue";
  135. char *Mailqueue    = "TCPIP:spool/mqueue/#?.wrk";
  136. char *Routeqdir    = "TCPIP:spool/rqueue";        /* queue for router */
  137. char *Alias    = "TCPIP:alias";        /* the alias file */
  138. char *Dfile    = "TCPIP:domain.txt";        /* Domain cache */
  139. char *Fdir    = "TCPIP:finger";        /* Finger info directory */
  140. char *Fdbase = "TCPIP:finger/dbase.dat"; /* Finger database */
  141. char *Arealist  = "TCPIP:spool/areas";      /* List of message areas */
  142. char *Helpdir    = "TCPIP:spool/help";        /* Mailbox help file directory */
  143. char *Rewritefile = "TCPIP:spool/rewrite";    /* Address rewrite file */
  144. char *Signature    = "TCPIP:spool/signatur";    /* Mail signature file directory */
  145. char *Popusers    = "TCPIP:/popusers";        /* POP user and password file */
  146. char *Newsdir    = "TCPIP:spool/news";        /* News messages and NNTP data */
  147. char *Forwardfile = "TCPIP:spool/forward.bbs";    /* Mail forwarding file */
  148. char *Historyfile = "TCPIP:spool/history";    /* Message ID history file */
  149. char *UDefaults = "TCPIP:spool/users.dat";  /* User preference file */
  150. char *Netromfile = "TCPIP:netrom.sav";      /* Netrom node save file */
  151. char *Onexit = "TCPIP:onexit.nos";           /* Commands to be executed on exiting */
  152. char *Expirefile = "TCPIP:spool/expire.dat"; /* Message expiration control file */
  153. #ifdef    NNTPS
  154. char *Active    = "TCPIP:spool/news/active";     /* */
  155. char *Pointer   = "TCPIP:spool/news/pointer";    /* */
  156. char *NInfo = "TCPIP:spool/news/info";       /* */
  157. char *Nhelp = "TCPIP:spool/news/help";       /* */
  158. char *History   = "TCPIP:spool/news/history";    /* */
  159. char *Forward   = "TCPIP:spool/news/forward";    /* */
  160. char *Poll  = "TCPIP:spool/news/poll";       /* */
  161. #endif
  162. char Eol[]    = "\r\n";
  163. #define    SEPARATOR    "/"
  164. #endif
  165.  
  166. #ifdef    MAC
  167. char *Startup    = "Mikes Hard Disk:nos.start";
  168. char *Config    = "Mikes Hard Disk:config.nos";    /* Device configuration list */
  169. char *Hostfile    = "Mikes Hard Disk:net.rc";    /* hosts and passwords */
  170. char *Userfile    = "Mikes Hard Disk:ftpusers";
  171. char *Mailspool    = "Mikes Hard Disk:spool:mail:";
  172. char *Maillog    = "Mikes Hard Disk:spool:mail.log:";
  173. char *Mailqdir    = "Mikes Hard Disk:spool:mqueue:";
  174. char *Mailqueue    = "Mikes Hard Disk:spool:mqueue:*.wrk";
  175. char *Routeqdir    = "Mikes Hard Disk:spool/rqueue:";    /* queue for router */
  176. char *Alias    = "Mikes Hard Disk:alias";        /* the alias file */
  177. char *Dfile    = "Mikes Hard Disk:domain:txt";        /* Domain cache */
  178. char *Fdir    = "Mikes Hard Disk:finger";        /* Finger info directory */
  179. char *Fdbase = "Mikes Hard Disk:finger/dbase.dat"; /* Finger database */
  180. char *Arealist  = "Mikes Hard Disk:spool/areas";    /* List of message areas */
  181. char *Helpdir    = "Mikes Hard Disk:spool/help";        /* Mailbox help file directory */
  182. char *Rewritefile = "Mikes Hard Disk:spool/rewrite";    /* Address rewrite file */
  183. char *Signature    = "Mikes Hard Disk:spool/signatur";    /* Mail signature file directory */
  184. char *Popusers    = "Mikes Hard Disk:/popusers";        /* POP user and password file */
  185. char *Newsdir    = "Mikes Hard Disk:spool/news";    /* News messages and NNTP data */
  186. char *Forwardfile = "Mikes Hard Disk:spool/forward.bbs"; /* Mail forwarding file */
  187. char *Historyfile = "Mikes Hard Disk:spool/history";    /* Message ID history file */
  188. char *UDefaults = "Mikes Hard Disk:spool/users.dat";  /* User preference file */
  189. char *Netromfile = "Mikes Hard Disk:netrom.sav";    /* Netrom node save file */
  190. char *Onexit = "Mikes Hard Disk:onexit.nos";           /* Commands to be executed on exiting */
  191. char *Expirefile = "Mikes Hard Disk:spool/expire.dat"; /* Message expiration control file */
  192. #ifdef    NNTPS
  193. char *Active    = "Mikes Hard Disk:spool/news/active";        /* */
  194. char *Pointer    = "Mikes Hard Disk:spool/news/pointer";    /* */
  195. char *NInfo    = "Mikes Hard Disk:spool/news/info";        /* */
  196. char *Nhelp    = "Mikes Hard Disk:spool/news/help";        /* */
  197. char *History    = "Mikes Hard Disk:spool/news/history";    /* */
  198. char *Forward    = "Mikes Hard Disk:spool/news/forward";    /* */
  199. char *Poll    = "Mikes Hard Disk:spool/news/poll";        /* */
  200. #endif
  201. char Eol[]    = "\r";
  202. #define    SEPARATOR    ":"
  203. #endif
  204.  
  205. static char *rootdir = ROOTDIR;
  206. static int Assigned;
  207. static int Initroot;
  208.  
  209. static void setname __ARGS((char *name,char *file));
  210. static void tabs_to_spaces __ARGS((char *p));
  211. void assign_filenames __ARGS((char *config));
  212.  
  213. extern void undosify __ARGS((char *s));
  214.  
  215. /* Establish a root directory other than the default. Can only be called
  216.  * once, at startup time
  217.  */
  218. void
  219. initroot(root)
  220. char *root;
  221. {
  222.     if(Assigned) {
  223.         tprintf("-f option used, -d ignored !\n");
  224.         return;
  225.     }
  226. #ifdef  MSDOS
  227.     undosify(root);
  228. #endif
  229.     rootdir = strdup( root );
  230.  
  231.     Startup = rootdircat(Startup);
  232.     Userfile = rootdircat(Userfile);
  233.     Hostfile = rootdircat(Hostfile);
  234.     Maillog = rootdircat(Maillog);
  235.     Mailspool = rootdircat(Mailspool);
  236.     Mailqdir = rootdircat(Mailqdir);
  237.     Mailqueue = rootdircat(Mailqueue);
  238.     Routeqdir = rootdircat(Routeqdir);
  239.     Alias = rootdircat(Alias);
  240.     Dfile = rootdircat(Dfile);
  241.     Fdir = rootdircat(Fdir);
  242.     Fdbase = rootdircat(Fdbase);
  243.     Arealist = rootdircat(Arealist);
  244.     Rewritefile = rootdircat(Rewritefile);
  245.     Ftpmotd = rootdircat(Ftpmotd);
  246. #ifdef MAILBOX
  247.     Signature = rootdircat(Signature);
  248.     Historyfile = rootdircat(Historyfile);
  249.     Helpdir = rootdircat(Helpdir);
  250.     Motdfile = rootdircat(Motdfile);
  251. #ifdef USERLOG
  252.     UDefaults = rootdircat(UDefaults);
  253.     UDefbak = rootdircat(UDefbak);
  254. #endif
  255. #endif
  256. #ifdef CONVERS
  257.     Cinfo = rootdircat(Cinfo);
  258. #endif
  259. #if (defined(POP) || defined(POP2CLIENT) || defined(POP2SERVER) || defined(POP3CLIENT) || defined(POP3SERVER))
  260.     Popusers = rootdircat(Popusers);
  261. #endif
  262. #if (defined(NNTP) || defined(NNTPS))
  263.     Newsdir = rootdircat(Newsdir);
  264. #endif
  265. #ifdef MBFWD
  266.     Forwardfile = rootdircat(Forwardfile);
  267. #endif
  268. #ifdef NETROM
  269.     Netromfile = rootdircat(Netromfile);
  270. #endif
  271.     Onexit = rootdircat(Onexit);
  272. #ifdef EXPIRY
  273.     Expirefile = rootdircat(Expirefile);
  274. #endif
  275. #ifdef    NNTPS
  276.     Active = rootdircat(Active);
  277.     Pointer = rootdircat(Pointer);
  278.     NInfo = rootdircat(NInfo);
  279.     Nhelp = rootdircat(Nhelp);
  280.     History = rootdircat(History);
  281.     Forward = rootdircat(Forward);
  282.     Poll = rootdircat(Poll);
  283. #endif
  284.     Initroot = 1;
  285. }
  286.  
  287. /* Concatenate root, separator and arg strings into a malloc'ed output
  288.  * buffer, then remove repeated occurrences of the separator char
  289.  */
  290. char *
  291. rootdircat(filename)
  292. char *filename;
  293. {
  294.     char *out = filename;
  295.  
  296.     if(strlen(rootdir) > 0){
  297.         char *separator = SEPARATOR;
  298.         out = mallocw(strlen(rootdir)
  299.             + strlen(separator)
  300.             + strlen(filename) +1);
  301.         strcpy(out,rootdir);
  302.         strcat(out,separator);
  303.         strcat(out,filename);
  304.         if(*separator != '\0'){
  305.             char *p1, *p2;
  306.         /* Remove any repeated occurrences */
  307.             p1 = p2 = out;
  308.             while(*p2 != '\0'){
  309.                 *p1++ = *p2++;
  310.                 while(p2[0] == p2[-1] && p2[0] == *separator)
  311.                     p2++;
  312.             }
  313.             *p1 = '\0';
  314.         }
  315.     }
  316.     return out;
  317. }
  318.  
  319. #ifdef PPP
  320. /* Read through FTPUSERS looking for user record
  321.  * Returns line which matches username, or NULLCHAR when no match.
  322.  * Each of the other variables must be copied before freeing the line.
  323.  */
  324. char *
  325. userlookup(username,password,directory,permission,ip_address)
  326. char *username;
  327. char **password;
  328. char **directory;
  329. long *permission;
  330. int32 *ip_address;
  331. {
  332.     FILE *fp;
  333.     char *buf;
  334.     char *cp;
  335.  
  336.     if((fp = fopen(Userfile,READ_TEXT)) == NULLFILE)
  337.         /* Userfile doesn't exist */
  338.         return NULLCHAR;
  339.  
  340.     buf = mallocw(128);
  341. #ifdef __GNUC__
  342.     cp = 0;            /* silence "uninitialized" warning */
  343. #endif
  344.     while ( fgets(buf,128,fp) != NULLCHAR ){
  345.         if(*buf == '#')
  346.             continue;    /* Comment */
  347.  
  348.         if((cp = strchr(buf,' ')) == NULLCHAR)
  349.             /* Bogus entry */
  350.             continue;
  351.         *cp++ = '\0';        /* Now points to password */
  352.  
  353.         if( stricmp(username,buf) == 0 )
  354.             break;        /* Found user */
  355.     }
  356.     if(feof(fp)){
  357.         /* username not found in file */
  358.         fclose(fp);
  359.         free(buf);
  360.         return NULLCHAR;
  361.     }
  362.     fclose(fp);
  363.  
  364.     if ( password != NULL )
  365.         *password = cp;
  366.  
  367.     /* Look for space after password field in file */
  368.     if((cp = strchr(cp,' ')) == NULLCHAR) {
  369.         /* Invalid file entry */
  370.         free(buf);
  371.         return NULLCHAR;
  372.     }
  373.     *cp++ = '\0';    /* Now points to directory field */
  374.  
  375.     if ( directory != NULL )
  376.         *directory = cp;
  377.  
  378.     if((cp = strchr(cp,' ')) == NULLCHAR) {
  379.         /* Permission field missing */
  380.         free(buf);
  381.         return NULLCHAR;
  382.     }
  383.     *cp++ = '\0';    /* now points to permission field */
  384.  
  385.     if (permission != NULL )
  386.         *permission = strtol( cp, NULLCHARP, 0 );
  387.  
  388.     if((cp = strchr(cp,' ')) == NULLCHAR) {
  389.         /* IP address missing */
  390.         if ( ip_address != NULL )
  391.             *ip_address = 0L;
  392.     } else {
  393.         *cp++ = '\0';    /* now points at IP address field */
  394.         if ( ip_address != NULL )
  395.             *ip_address = resolve( cp );
  396.     }
  397.     return buf;
  398. }
  399. #endif
  400.  
  401. /* Subroutine for logging in the user whose name is name and password is pass.
  402.    The buffer path should be long enough to keep a line from the userfile.
  403.    If pwdignore is true, the password check will be overridden.
  404.    The return value is the permissions field or -1 if the login failed.
  405.    Path is set to point at the path field, and pwdignore will be true if no
  406.    particular password was needed for this user.
  407.  */
  408. long
  409. userlogin(name,pass,path,len,pwdignore)
  410. char *name;
  411. char *pass;
  412. char **path;
  413. int len;            /* Length of buffer pointed at by *path */
  414. int *pwdignore;
  415. {
  416.     char *cp,*cp1;
  417.     FILE *fp;
  418.     char *universal = NULLCHAR;
  419.     int anony,perm;
  420.  
  421.     if((fp = fopen(Userfile,READ_TEXT)) == NULLFILE)
  422.         /* Userfile doesn't exist */
  423.         return -1;
  424. #ifdef __GNUC__
  425.     cp = 0;            /* silence warning */
  426. #endif
  427.     while(fgets(*path,len,fp),!feof(fp)){
  428.         if(*path[0] == '#')
  429.             continue;    /* Comment */
  430.         if((cp = strchr(*path,' ')) == NULLCHAR)
  431.             /* Bogus entry */
  432.             continue;
  433.         *cp++ = '\0';        /* Now points to password */
  434.         if(stricmp(name,*path) == 0)
  435.             break;        /* Found user name */
  436.         if(stricmp("univperm",*path) == 0)
  437.             universal = strdup(cp);    /* remember their anon entry */
  438.     }
  439.     if((universal == NULLCHAR) && (feof(fp))){
  440.         /* User name not found in file, nor was univperm */
  441.         fclose(fp);
  442.         /* No need to free universal ( == NULLCHAR ) remember !!! */
  443.         return -1;
  444.     }
  445.     if(feof(fp)){
  446.         /* restore anonymous to the buffer */
  447.         strcpy(cp = *path, universal);
  448.         free(universal);
  449.         universal = NULLCHAR;
  450.     }
  451.     if(universal != NULLCHAR)
  452.         free(universal);
  453.     fclose(fp);
  454.     /* Look for space after password field in file */
  455.     if((cp1 = strchr(cp,' ')) == NULLCHAR)
  456.         /* Invalid file entry */
  457.         return -1;
  458.     *cp1++ = '\0';    /* Now points to path field */
  459.     anony = *pwdignore;
  460.     if(strcmp(cp,"*") == 0)
  461.         anony = 1;    /* User ID is password-free */
  462.     if(!anony && strcmp(cp,pass) != 0)
  463.         /* Password required, but wrong one given */
  464.         return -1;
  465.     if((cp = strchr(cp1,' ')) == NULLCHAR)
  466.         /* Permission field missing */
  467.         return -1;
  468.     *cp++ = '\0';    /* now points to permission field */
  469.     if(!strnicmp(cp,"0x",2))
  470.         perm = htol(cp);
  471.     else
  472.         perm = atol(cp);
  473. #if   defined(AMIGA)
  474.     /*
  475.      * Well, on the Amiga, a file can be referenced by many names:
  476.      * device names (DF0:) or volume names (My_Disk:).  This hunk of code
  477.      * passed the pathname specified in the ftpusers file, and gets the
  478.      * absolute path copied into the user's buffer.  We really should just
  479.      * allocate the buffer and return a pointer to it, since the caller
  480.      * really doesn't have a good idea how long the path string is..
  481.      */
  482.     cp1 = pathname("", cp1);
  483.     if (cp1)
  484.         strcpy(*path, cp1);
  485.     else
  486.         **path = '\0';
  487.     free(cp1);
  488. #else
  489.     strcpy(*path,cp1);
  490.     /* Convert any backslashes to forward slashes, for backward
  491.      * compatibility with the old NET
  492.      */
  493.     while((cp = strchr(*path,'\\')) != NULLCHAR)
  494.         *cp = '/';
  495. #endif
  496.     *pwdignore = anony;
  497.     /* Finally return the permission bits */
  498.     return perm;
  499. }
  500.  
  501. #if defined(MSDOS) || defined(UNIX)
  502. void setname(char *name,char *file) {
  503.  
  504.     if(!stricmp("Startup",name)) {
  505.         if(Initroot)
  506.             free(Startup);
  507.         Startup = strdup(file);
  508.     } else if(!stricmp("Userfile",name)) {
  509.         if(Initroot)
  510.             free(Userfile);
  511.         Userfile = strdup(file);
  512.     } else if(!stricmp("Hostfile",name)) {
  513.         if(Initroot)
  514.             free(Hostfile);
  515.         Hostfile = strdup(file);
  516.     } else if(!stricmp("Maillog",name)) {
  517.         if(Initroot)
  518.             free(Maillog);
  519.         Maillog = strdup(file);
  520.     } else if(!stricmp("Mailspool",name)) {
  521.         if(Initroot)
  522.             free(Mailspool);
  523.         Mailspool = strdup(file);
  524.     } else if(!stricmp("Mailqdir",name)) {
  525.         if(Initroot)
  526.             free(Mailqdir);
  527.         Mailqdir = strdup(file);
  528.     } else if(!stricmp("Mailqueue",name)) {
  529.         if(Initroot)
  530.             free(Mailqueue);
  531.         Mailqueue = strdup(file);
  532.     } else if(!stricmp("Routeqdir",name)) {
  533.         if(Initroot)
  534.             free(Routeqdir);
  535.         Routeqdir = strdup(file);
  536.     } else if(!stricmp("Alias",name)) {
  537.         if(Initroot)
  538.             free(Alias);
  539.         Alias = strdup(file);
  540.     } else if(!stricmp("Dfile",name)) {
  541.         if(Initroot)
  542.             free(Dfile);
  543.         Dfile = strdup(file);
  544.     } else if(!stricmp("Fdir",name)) {
  545.         if(Initroot)
  546.             free(Fdir);
  547.         Fdir = strdup(file);
  548.     } else if(!stricmp("Fdbase",name)) {
  549.         if(Initroot)
  550.             free(Fdbase);
  551.         Fdbase = strdup(file);
  552.     } else if(!stricmp("Arealist",name)) {
  553.         if(Initroot)
  554.             free(Arealist);
  555.         Arealist = strdup(file);
  556.     } else if(!stricmp("Rewritefile",name)) {
  557.         if(Initroot)
  558.             free(Rewritefile);
  559.         Rewritefile = strdup(file);
  560.     } else if(!stricmp("Onexit",name)) {
  561.         if(Initroot)
  562.             free(Onexit);
  563.         Onexit = strdup(file);
  564.     } else if(!stricmp("Ftpmotd",name)) {
  565.         if(Initroot)
  566.             free(Ftpmotd);
  567.         Ftpmotd = strdup(file);
  568.     }
  569. #ifdef MAILBOX
  570.     else if(!stricmp("Signature",name)) {
  571.         if(Initroot)
  572.             free(Signature);
  573.         Signature = strdup(file);
  574.     } else if(!stricmp("Historyfile",name)) {
  575.         if(Initroot)
  576.             free(Historyfile);
  577.         Historyfile = strdup(file);
  578.     } else if(!stricmp("Helpdir",name)) {
  579.         if(Initroot)
  580.             free(Helpdir);
  581.         Helpdir = strdup(file);
  582.     } else if(!stricmp("Motdfile",name)) {
  583.         if(Initroot)
  584.             free(Motdfile);
  585.         Motdfile = strdup(file);
  586.     }
  587. #ifdef USERLOG
  588.     else if(!stricmp("UDefaults",name)) {
  589.         if(Initroot)
  590.             free(UDefaults);
  591.         UDefaults = strdup(file);
  592.     } else if(!stricmp("UDefbak",name)) {
  593.         if(Initroot)
  594.             free(UDefbak);
  595.         UDefbak = strdup(file);
  596.     }
  597. #endif
  598. #endif
  599. #ifdef CONVERS
  600.     else if(!stricmp("Cinfo",name)) {
  601.         if(Initroot)
  602.             free(Cinfo);
  603.         Cinfo = strdup(file);
  604.     }
  605. #endif
  606. #if (defined(POP) || defined(POP2CLIENT) || defined(POP2SERVER) || defined(POP3CLIENT) || defined(POP3SERVER))
  607.     else if(!stricmp("Popusers",name)) {
  608.         if(Initroot)
  609.             free(Popusers);
  610.         Popusers = strdup(file);
  611.     }
  612. #endif
  613. #if (defined(NNTP) || defined(NNTPS))
  614.     else if(!stricmp("Newsdir",name)) {
  615.         if(Initroot)
  616.             free(Newsdir);
  617.         Newsdir = strdup(file);
  618.     }
  619. #endif
  620. #ifdef MBFWD
  621.     else if(!stricmp("Forwardfile",name)) {
  622.         if(Initroot)
  623.             free(Forwardfile);
  624.         Forwardfile = strdup(file);
  625.     }
  626. #endif
  627. #ifdef NETROM
  628.     else if(!stricmp("Netromfile",name)) {
  629.         if(Initroot)
  630.             free(Netromfile);
  631.         Netromfile = strdup(file);
  632.     }
  633. #endif
  634. #ifdef EXPIRY
  635.     else if(!stricmp("Expirefile",name)) {
  636.         if(Initroot)
  637.             free(Expirefile);
  638.         Expirefile = strdup(file);
  639.     }
  640. #endif
  641. #ifdef NNTPS
  642.     else if(!stricmp("Active",name)) {
  643.         if(Initroot)
  644.             free(Active);
  645.         Active = strdup(file);
  646.     } else if(!stricmp("Pointer",name)) {
  647.         if(Initroot)
  648.             free(Pointer);
  649.         Pointer = strdup(file);
  650.     } else if(!stricmp("NInfo",name)) {
  651.         if(Initroot)
  652.             free(NInfo);
  653.         NInfo = strdup(file);
  654.     } else if(!stricmp("Nhelp",name)) {
  655.         if(Initroot)
  656.             free(Nhelp);
  657.         Nhelp = strdup(file);
  658.     } else if(!stricmp("History",name)) {
  659.         if(Initroot)
  660.             free(History);
  661.         History = strdup(file);
  662.     } else if(!stricmp("Forward",name)) {
  663.         if(Initroot)
  664.             free(Forward);
  665.         Forward = strdup(file);
  666.     } else if(!stricmp("Poll",name)) {
  667.         if(Initroot)
  668.             free(Poll);
  669.         Poll = strdup(file);
  670.     }
  671. #endif
  672. #ifdef UNIX
  673.     else if (stricmp(name, "Command") == 0)
  674.     {
  675.     if (Initroot) free(Command_sessmgr);
  676.     Command_sessmgr = strdup(file);
  677.     }
  678.     else if (stricmp(name, "Trace") == 0)
  679.     {
  680.     if (Initroot) free(Trace_sessmgr);
  681.     Trace_sessmgr = strdup(file);
  682.     }
  683. #endif
  684. }
  685.  
  686. void tabs_to_spaces(char *p) {
  687.     while(*p != '\0') {
  688.         if(*p == '\t')
  689.             *p = ' ';
  690.         p++;
  691.     }
  692. }
  693.  
  694. void
  695. assign_filenames(char *config) {
  696.     FILE *fp;
  697.     char *name,*file,*cp;
  698.     int line;
  699. #define BUFLEN 128
  700.     char buf[BUFLEN+1];
  701.  
  702. #ifdef MSDOS
  703.     undosify(config);
  704. #endif
  705.     if((fp = fopen(config,"r")) == NULL) {
  706.         tprintf("Cannot open %s\n",config);
  707.         return;
  708.     }
  709.  
  710.     line = 0;
  711.     while(fgets(buf,BUFLEN,fp) != NULL) {
  712.         line++;
  713.         if(*buf == '#')         /* comment */
  714.             continue;
  715.         rip(buf);   /* delete ending \n */
  716.         tabs_to_spaces(buf);
  717.         name = buf;
  718.         while(*name == ' ')    /* no leading spaces */
  719.             name++;
  720.         if(*name == '\0')      /* blank line */
  721.             continue;
  722.         /* Search for filename */
  723.         if((file = strchr(name,'=')) == NULL) {
  724.             tprintf("Need '=', line %d of %s.\n",line,config);
  725.             continue;
  726.         }
  727.         *file++ = '\0';
  728.         /* cut trailing spaces */
  729.         if((cp = strchr(name,' ')) != NULL)
  730.             *cp = '\0';
  731.  
  732.         /* find start of filename */
  733.         while(*file == ' ')
  734.             file++;
  735.  
  736.         if(*file == '\0')
  737.             continue;
  738.  
  739.         /* cut trailing spaces */
  740.         if((cp = strchr(file,' ')) != NULL)
  741.             *cp = '\0';
  742.  
  743.         /* Now parse the name, and assign if valid */
  744.         setname(name,file);
  745.     }
  746.     fclose(fp);
  747.     Assigned = 1;
  748. }
  749. #endif
  750.  
  751.